//
//  CSYEmoticonPackageModel.swift
//  CSYEmoticonKeyboard__Test
//
//  Created by 姚彦兆 on 15/11/21.
//  Copyright © 2015年 姚彦兆. All rights reserved.
//

import UIKit

class CSYEmoticonPackageModel: NSObject {

    
    lazy var emoticonModelArray : [CSYEmoticonModel] = [CSYEmoticonModel]()
    
    //文件夹名称
    var id : String?

    //表情昵称
    var group_name_cn : String?
    
    init(id : String , group_name_cn : String , plistData : [[String : AnyObject]]){

        self.id = id
        
        self.group_name_cn = group_name_cn
        
        super.init()
        
        setData(id, plistData: plistData)
        
    }
    
    private func setData(id : String , plistData : [[String : AnyObject]]){
        
        var index : NSInteger = 0
        
        for item in plistData{
        
            let emoticonModel : CSYEmoticonModel = CSYEmoticonModel(id: id, emoticonDict: item)
        
            emoticonModelArray.append(emoticonModel)
        
            index++
            
            if index == 20 {
            
                emoticonModelArray.append(CSYEmoticonModel(isRemove: true))
            
                index = 0
                
            }
            
        }
        
        insertEmptyBtn()
    
    }
    
    private func insertEmptyBtn(){
    
        let count : NSInteger = emoticonModelArray.count % 21
    
        if count == 0 {
        
            return
        
        }
        
        for _ in count ..< 20 {
        
            emoticonModelArray.append(CSYEmoticonModel(isEmpty: true))
        
        }
    
        emoticonModelArray.append(CSYEmoticonModel(isRemove: true))
    
    }
    
    
    
    
    
    
    
}
